<!DOCTYPE html>
<!--
/*******************************************************************************
#      ____               __          __  _      _____ _       _               #
#     / __ \              \ \        / / | |    / ____| |     | |              #
#    | |  | |_ __   ___ _ __ \  /\  / /__| |__ | |  __| | ___ | |__   ___      #
#    | |  | | '_ \ / _ \ '_ \ \/  \/ / _ \ '_ \| | |_ | |/ _ \| '_ \ / _ \     #
#    | |__| | |_) |  __/ | | \  /\  /  __/ |_) | |__| | | (_) | |_) |  __/     #
#     \____/| .__/ \___|_| |_|\/  \/ \___|_.__/ \_____|_|\___/|_.__/ \___|     #
#           | |                                                                #
#           |_|                 _____ _____  _  __                             #
#                              / ____|  __ \| |/ /                             #
#                             | (___ | |  | | ' /                              #
#                              \___ \| |  | |  <                               #
#                              ____) | |__| | . \                              #
#                             |_____/|_____/|_|\_\                             #
#                                                                              #
#                              (c) 2010-2011 by                                #
#           University of Applied Sciences Northwestern Switzerland            #
#                     Institute of Geomatics Engineering                       #
#                           martin.christen@fhnw.ch                            #
********************************************************************************
*     Licensed under MIT License. Read the file LICENSE for more information   *
*******************************************************************************/

          TUTORIAL 2: Creating a virtual globe with OpenStreetMap Data
*******************************************************************************/
-->
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="../../../external/closure-library/closure/goog/base.js"></script>
<script type="text/javascript" src="../../../compiled/deps.js"></script>
<script type="text/javascript">goog.require('owg.OpenWebGlobe');</script>

<script type="text/javascript">

//------------------------------------------------------------------------------
// called every frame:
function OnRender(context)
{
   ogSetTextColor(context, 0,1,0);
   ogDrawText(context, "Hello World", 0, 20);
}

function OnKeyDown(ctx,key)
{
   var scene = ogGetScene(ctx);

   if(key == 49) // 1 - CH
   {
      //normal Fly-To Camera moves to the desired position.
      //camera orientation remains the same.
      
      ogFlyTo(scene,116.261687, 40.099347, 1000); //scene,longitude,latitude,elevation
      
   }
   if(key == 50) // 1 - 
   {
      //normal Fly-To Camera moves to the desired position.
      //camera orientation remains the same.
      
      ogFlyTo(scene,7, 46, 10000); //scene,longitude,latitude,elevation
      
   }
   if(key == 51) // 1 - 
   {
      //normal Fly-To Camera moves to the desired position.
      //camera orientation remains the same.
      
      ogFlyTo(scene,-74,41, 10000); //scene,longitude,latitude,elevation  
   }
   if(key == 52) // 1 - 
   {
      //normal Fly-To Camera moves to the desired position.
      //camera orientation remains the same.
      
      ogFlyTo(scene,151,-33, 10000); //scene,longitude,latitude,elevation  
   }
   if(key == 53) // 1 - 
   {
      //normal Fly-To Camera moves to the desired position.
      //camera orientation remains the same.
      
      ogFlyTo(scene,0,90, 10000); //scene,longitude,latitude,elevation  
   }
      if(key == 54) // 1 - 
   {
      //normal Fly-To Camera moves to the desired position.
      //camera orientation remains the same.
      
      ogFlyTo(scene,0,-90, 10000); //scene,longitude,latitude,elevation  
   }
}
     
//------------------------------------------------------------------------------
function main()
{
   // (0) Set location of Artwork directory. Because of CORS this can't be local
   // if you want to open this using file://...
   ogSetArtworkDirectory("http://www.openwebglobe.org/art/");
   
   // (1) create an OpenWebGlobe context using canvas
   // first parameter is canvas-id and second is "fullscreen"
   var ctx = ogCreateContextFromCanvas("canvas", true);
   
   // (2) Create a virtual globe
   var globe = ogCreateGlobe(ctx);
   
   // (3) Add openstreet image layer
   
   var imgOpenStreetMap = 
   {
      url     : ["http://a.tile.openstreetmap.org", "http://b.tile.openstreetmap.org", "http://c.tile.openstreetmap.org" ],
      service : "osm"
   };
   ogAddImageLayer(globe, imgOpenStreetMap);
   
   // (4) Set Color of north, south pole to match the "OpenStreetMap Color"
   ogSetNorthpoleColor(globe, 181/255,208/255,208/255);
   ogSetSouthpoleColor(globe, 241/255,238/255,232/255);

   // (5) Set the "Render-Callback" function.
   // The callback function will be called everytime a frame is drawn.
   ogSetRenderFunction(ctx, OnRender);
   
   // (6) Set the background color
   ogSetBackgroundColor(ctx, 0.2,0.2,0.7,1);
   ogSetKeyDownFunction(ctx, OnKeyDown);
}
//------------------------------------------------------------------------------
   
</script>

</head>
<body onload="main()" style="padding:0px; margin:0px; overflow:hidden;">
   <div style="text-align: center">
   <canvas id="canvas"></canvas>          
   </div>
</body>
</html>
